<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/jsp/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>jqGird</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="${ctxStatic}/plugins/h+/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="${ctxStatic}/plugins/h+/css/plugins/webuploader/webuploader.css">
    <link href="${ctxStatic}/plugins/h+/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">

    <link href="${ctxStatic}/plugins/h+/css/font-awesome.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/colorpicker/css/bootstrap-colorpicker.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/cropper/cropper.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/switchery/switchery.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/jasny/jasny-bootstrap.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/nouslider/jquery.nouislider.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/ionRangeSlider/ion.rangeSlider.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/clockpicker/clockpicker.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/style.min.css?v=4.0.0" rel="stylesheet"><base target="_blank">
    <link href="${pageContext.request.contextPath}/resources/plugins/h+/css/plugins/jsTree/style.min.css" rel="stylesheet">
    <style>
        .ml10 {
            margin-left: 15px;
        }
        .chosen-container{
            width:100% !important;
        }

    </style>

</head>

<body class="gray-bg" >

<div class="panel blank-panel">

<div class="panel-heading">
    <div class="panel-options">
        <ul class="nav nav-tabs">
            <li class="active" style="width:33%;"><a data-toggle="tab" href="tabs_panels.html#tab-1">自动发券</a>
            </li>
            <li class="" style="width:33%;"><a data-toggle="tab" href="tabs_panels.html#tab-2">手动发券</a>
            </li>
<shiro:hasAnyRoles name="admin,代理商">
    <li class="" style="width:33%;"><a data-toggle="tab" href="tabs_panels.html#tab-3">实体卡</a>
            </li>
    </shiro:hasAnyRoles>
        </ul>
    </div>
</div>

    <div class="panel-body">
        <div class="tab-content">
            <div id="tab-1" class="tab-pane active">
                <jsp:include page="autoQuery.jsp"></jsp:include>
            </div>
            <div id="tab-2" class="tab-pane">
              <jsp:include page="manualQuery.jsp"></jsp:include>
            </div>
            <div id="tab-3" class="tab-pane">
                <jsp:include page="cardQuery.jsp"></jsp:include>
            </div>
        </div>
</div>


    <script src="${ctxStatic}/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
    <script src="${ctxStatic}/plugins/h+/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/bootstrap-table.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/locale/bootstrap-table-zh-CN.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/export/bootstrap-table-export.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/editable/bootstrap-table-editable.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/sweetalert/sweetalert.min.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/content.min.js?v=1.0.0"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/chosen/chosen.jquery.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/layer/laydate/laydate.js"></script>
    <script>

    </script>
    <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
    <script type="text/javascript">
        //初始化表格对象
        var $table = $('#exampleTablePagination');
        var $table2 = $('#exampleTablePagination2');
        var $table3= $('#exampleTablePagination3');
        $('#search_type').chosen({   no_results_text : "未找到此选项!",
            width:"100%"});
        loadAgentList();
        loadBrandList("","");
        loadBrandList("","2");
        loadShopList("","");
        loadShopList("","2");
        loadZDInfo();
        loadSDInfo();
        loadSTKInfo();
        loadTradeType();
        loadCardType();
        ////////////////////////////////////////////////////////////////////////////////////////以下是通过js方式初始化BootStrapTable/////////////////////////////////////////////

        $table.bootstrapTable({
            url: "${pageContext.request.contextPath}/baseDetail/showBaseDetail.ac?type=1",
            method: 'post',
            contentType: "application/x-www-form-urlencoded",//必须的
            dataType: "json",
            pageList:[10, 20, 50, 100],//会根据当前的数据量加载合适的pageList
            height: ($(window).height()-100) ,
            pagination: true, //分页
            singleSelect: false,
            cache:false,
            sortName:"name",
            search: false, //显示搜索框
            showColumns:false,
            showRefresh:false,
            showToggle:false,
            showPaginationSwitch:false,
            smartDisplay:true,
            detailView:false,
            toolbar:"#toolbar",
            queryParams: queryParams,//参数
            searchOnEnterKey:true,
            detailFormatter:function(index, row, element){
                return row.customer;
            },
            sidePagination: "server", //服务端处理分页
            columns: [
                {
                    visible:false,
                    field:'id'
                },
                {
                    title: '代理商',
                    field: 'agent_name',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                }, {
                    title: '商户',
                    field: 'brand_name',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },{
                    title: '门店',
                    field: 'business_name',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },
                {  title: '订单编号',
                    field: 'code',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },{
                    title: '订单金额',
                    field: 'order_total',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center',
                    formatter:function(value,row,index){
                        return (value/100).toFixed(2);

                    }
                },{
                    title: '发券金额',
                    field: 'gift_90',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center',
                    formatter:function(value,row,index){
                        if(row.state!=2){ return (value/100).toFixed(2);}
                         else return 0;
                    }
                },
                {
                    title: '发券费率',
                    field: 'commission',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center',
                    formatter:function(value,row,index){
                        return value+"%";
                    }
                },{
                    title: '发券费用',
                    field: 'card_fee',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center',
                    formatter:function(value,row,index){
                        if(row.state!=2){
                            //return (value/100).toFixed(2);
                            return value;
                        }
                        else return 0;
                    }
                },
                {
                    title: '交易状态',
                    field: 'state',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center',
                    formatter:function(value,row,index){
                        var state='';
                        if(value==0)
                        {state='未生效';}
                        else  if(value==1)
                        {state='交易成功';}
                        else  if(value==2)
                        {state='错误';}
                        else  if(value==3)
                        {state='已退款';}

                        return state;
                    }
                },
                {  title: '收银员',
                    field: 'person_name',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                }
              ,{  title: '支付类型',
                    field: 'trade_type',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center',
                    formatter:function(value,row,index){
                        var state='';
                        if(value=='MICROPAY')
                        {state='微支付';}
                        else  if(value=='ZFB-MICROPAY')
                        {state='支付宝';}
                        else  if(value=='UNIONPAY')
                        {state='银联';}
                        else  if(value=='offline')
                        {state='线下支付';}
                        return state;
                    }
                },
                {  title: '领券人',
                    field: 'userName',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },
                {  title: '领券手机号',
                    field: 'userPhone',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                }
                ,{
                    title: '发券时间',
                    field: 'create_time',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                }
            ]
        });

        $table2.bootstrapTable({
            url: "${pageContext.request.contextPath}/baseDetail/showBaseDetail.ac?type=2",
            method: 'post',
            contentType: "application/x-www-form-urlencoded",//必须的
            dataType: "json",
            pageList:[10, 20, 50, 100],//会根据当前的数据量加载合适的pageList
            height: ($(window).height()-100) ,
            //cardView:true,//是否自适应手机
            pagination: true, //分页
            // queryParamsType: "limit",
            singleSelect: false,
            cache:false,
            sortName:"name",
            search: false, //显示搜索框
            showColumns:false,
            showRefresh:false,
            showToggle:false,
            showPaginationSwitch:false,
            smartDisplay:true,
            detailView:false,
            toolbar:"#toolbar",
            queryParams: queryParams2,//参数
            searchOnEnterKey:true,
            sidePagination: "server", //服务端处理分页
            columns: [
                {
                    visible:false,
                    field:'id'
                },
                {
                    title: '代理商',
                    field: 'agentName',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                }, {
                    title: '商户',
                    field: 'brandName',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },{
                    title: '门店',
                    field: 'shopIdName',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },{
                    title: '发券金额',
                    field: 'point90',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center',
                    formatter:function(value,row,index){
                        return (value/100).toFixed(2);
                    }
                },
                {
                    title: '交易状态',
                    field: 'orderState',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center',
                    formatter:function(value,row,index){
                        var state='';
                        if(value==0)
                        {state='未生效';}
                        else  if(value==1)
                        {state='交易成功';}
                        else  if(value==2)
                        {state='错误';}
                        else  if(value==3)
                        {state='已退款';}

                        if(row.isdel==1){
                            state='已撤销';
                        }

                        return state;
                    }
                },{  title: '发券人',
                    field: 'operUserName',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },
                {  title: '发券终端',
                    field: 'type',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'  ,
                    formatter:function(value,row,index) {
                        var fqzd = '';
                        if (value == 0) {
                            fqzd = 'pos机';
                        }
                        else if (value == 1) {
                            fqzd = 'QT';
                        }
                        else if (value == 2) {
                            fqzd = '微商城';
                        }
                        else if (value == 3) {
                            fqzd = '远程发券';
                        }
                        else {
                            fqzd = '其他';
                        }
                        return fqzd;
                    }
                },{  title: '领券人',
                    field: 'userName',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },
                {  title: '领券手机号',
                    field: 'userPhone',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },{
                    title: '发券时间',
                    field: 'createTime',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },
                /*{
                    title: '撤回时间',
                    field: 'cancelTime',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },*/
                {
                    title: '操作/撤销时间',
                    align: 'center',
                    events:{
                        'click .remove': function (e, value, row, index) {
                            var arr=[row.id];
                            deleteCX(arr);
                        }
                    },
                    formatter:function(value,row,index){

                        if(row.isdel==1){
                            return row.cancelTime;
                        }else{
                            return [
                                '<a class="remove ml10" href="javascript:void(0)" title="撤销">',
                                '<i class="glyphicon glyphicon-share-alt"></i>',
                                '</a>'
                            ].join('');
                        }

                    }
                }

            ]
        });

        $table3.bootstrapTable({
            url: "${pageContext.request.contextPath}/baseDetail/showBaseDetail.ac?type=4",
            method: 'post',
            contentType: "application/x-www-form-urlencoded",//必须的
            dataType: "json",
            pageList:[10, 20, 50, 100],//会根据当前的数据量加载合适的pageList
            height: ($(window).height()-100) ,
            //cardView:true,//是否自适应手机
            pagination: true, //分页
            // queryParamsType: "limit",
            singleSelect: false,
            cache:false,
            sortName:"name",
            search: false, //显示搜索框
            showColumns:false,
            showRefresh:false,
            showToggle:false,
            showPaginationSwitch:false,
            smartDisplay:true,
            detailView:false,
            toolbar:"#toolbar",
            queryParams: queryParams3,//参数
            searchOnEnterKey:true,
            detailFormatter:function(index, row, element){
                return row.customer;
            },
            sidePagination: "server", //服务端处理分页
            columns: [
                {
                    visible:false,
                    field:'id'
                },
                {
                    title: '实体卡名称',
                    field: 'cardName',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },
                {
                    title: '实体卡类型',
                    field: 'cardType',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },
                {
                    title: '实体卡密钥',
                    field: 'cardCode',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },
                {
                    title: '实体卡号',
                    field: 'sourceId',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },
              {
                    title: '发券金额',
                    field: 'point90',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center',
                    formatter:function(value,row,index){
                        return (value/100).toFixed(2);
                    }
                },{  title: '领券人',
                    field: 'userName',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },
                {  title: '领券手机号',
                    field: 'userPhone',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },{
                    title: '发券时间',
                    field: 'createTime',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                }

            ]
        });

        //批量导出
        $("#btn_export1").click(function(){
            var agent=$("#search_agent").val();
            var brand=$("#search_brand").val();
            var shop=$("#search_shop").val();
            var start=$("#search_startdate").val();
            var end=$("#search_enddate").val();
            var phone=$("#search_phone").val();
            var tradeType=$("#search_tradeType").val();
            window.location.href="${pageContext.request.contextPath}/baseDetail/doExcel.ac?type=1&agent="+agent+"&brand="+brand+"&shop="+shop+"&start="+start+"&end="+end+"&tradeType="+tradeType+"&phone="+phone;
        });
        $("#btn_export2").click(function(){
            var agent=$("#search_agent2").val();
            var brand=$("#search_brand2").val();
            var shop=$("#search_shop2").val();
            var start=$("#search_startdate2").val();
            var end=$("#search_enddate2").val();
            var phone=$("#search_phone2").val();
            window.location.href="${pageContext.request.contextPath}/baseDetail/doExcel.ac?type=2&agent="+agent+"&brand="+brand+"&shop="+shop+"&start="+start+"&end="+end+"&phone="+phone;
        });
        $("#btn_export3").click(function(){
            var agent="";
            var brand="";
            var start=$("#search_startdate3").val();
            var end=$("#search_enddate3").val();
            var phone=$("#search_phone3").val();
            var cardTypeId=$("#search_cardType").val();
            window.location.href="${pageContext.request.contextPath}/baseDetail/doExcel.ac?type=4&agent="+agent+"&brand="+brand+"&start="+start+"&end="+end+"&phone="+phone+"&cardTypeId="+cardTypeId;
        });
        /*
         搜索按钮
         */
        $("#btn_search").click(function(){
            $table.bootstrapTable('selectPage', 1);
            $table.bootstrapTable('refresh', queryParams);
            loadZDInfo();
        });
        /*
         搜索按钮
         */
        $("#btn_search2").click(function(){
            $table2.bootstrapTable('selectPage', 1);
            $table2.bootstrapTable('refresh', queryParams2);
            loadSDInfo();
        });
        /*
         搜索按钮
         */
        $("#btn_search3").click(function(){
            $table3.bootstrapTable('selectPage', 1);
            $table3.bootstrapTable('refresh', queryParams3);
            loadSTKInfo();
        });

        /*
         传递的参数
         */
        function queryParams(params) {
            var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                limit: params.limit,  //页面大小
                offset: params.offset, //页码
                pageindex:params.pageNumber,
                agent: $("#search_agent").val(),
                brand: $("#search_brand").val(),
                shop: $("#search_shop").val(),
                type: $("#search_type").val(),
                start: $("#search_startdate").val(),
                end: $("#search_enddate").val(),
                phone:$("#search_phone").val(),
                tradeType:$("#search_tradeType").val()
            };
            return temp;
        }


        /*
         传递的参数
         */
        function queryParams3(params) {
            var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                limit: params.limit,  //页面大小
                offset: params.offset, //页码
                pageindex:params.pageNumber,
                agent: $("#").val(),
                brand: $("#search_brand3").val(),
                type: $("#search_type3").val(),
                start: $("#search_startdate3").val(),
                end: $("#search_enddate3").val(),
                phone:$("#search_phone3").val(),
                cardType:$("#search_cardType3").val()
            };
            return temp;
        }


        /*
         传递的参数
         */
        function queryParams2(params) {
            var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                limit: params.limit,  //页面大小
                offset: params.offset, //页码
                pageindex:params.pageNumber,
                agent: $("#search_agent2").val(),
                brand: $("#search_brand2").val(),
                shop: $("#search_shop2").val(),
                type: $("#search_type2").val(),
                start: $("#search_startdate2").val(),
                end: $("#search_enddate2").val(),
                phone:$("#search_phone2").val()
            };
            return temp;
        }

        function loadTradeType(){
            $('#search_tradeType').chosen({
                no_results_text : "未找到此选项!",
                width:"100%"
            });
        }

        function loadCardType(){
            $.ajax({
                url:'${pageContext.request.contextPath}/baseDetail/getOfflineCardTypeForSelect.ac',
                data:{},
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data){
                    var html='<option value=""></option>';
                    if(data!=null&&data.length>0){
                        for(var i=0;i<data.length;i++)
                        {
                            html+='<option value="'+data[i].id+'">'+data[i].name+'</option>';
                        }
                    }
                    $("#search_cardType3").html(html);
                    $('#search_cardType3').chosen({
                        no_results_text : "未找到此选项!",
                        width:"100%"
                    });
                }
            });
        }

        function loadAgentList()//加载代理商列表
        {

            $.ajax( {
                url:'${pageContext.request.contextPath}/agent/getAgentListForSelect.ac',// 跳转到 action
                data:{},
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    var html='<option value=""></option>';
                    for(var i=0;i<data.length;i++)
                    {

                        html+='<option value="'+data[i].agent_code+'">'+data[i].agent_name+'</option>';

                    }

                    $("#search_agent").html(html);
                    $('#search_agent').chosen({
                        no_results_text : "未找到此选项!",
                        width:"100%"
                    });
                    $("#search_agent2").html(html);
                    $('#search_agent2').chosen({
                        no_results_text : "未找到此选项!",
                        width:"100%"
                    });
                    $("#search_agent").trigger("chosen:updated");
                    $("#search_agent2").trigger("chosen:updated");
                    $("#search_agent").chosen().change(function(){
                        loadBrandList($("#search_agent").val(),"");
                    });

                    $("#search_agent2").chosen().change(function(){
                        loadBrandList($("#search_agent2").val(),"2");
                    });
                },
                error : function() {
                    alert("加载代理商列表失败！");
                }
            });
        }

        function loadBrandList(pid,type)//加载代理商列表
        {

            $.ajax( {
                url:'${pageContext.request.contextPath}/merchant/getBrandListForSelect.ac',// 跳转到 action
                data:{pid:pid},
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    var html='<option value=""></option>';
                    for(var i=0;i<data.length;i++)
                    {

                        html+='<option value="'+data[i].brand_code+'">'+data[i].name+'</option>';

                    }

                    $("#search_brand"+type).html(html);
                    $('#search_brand'+type).chosen({
                        no_results_text : "未找到此选项!",
                        width:"100%"
                    });
                    $('#search_brand'+type).trigger("chosen:updated");
                    $("#search_brand").chosen().change(function(){
                        loadShopList($("#search_brand").val(),"");
                    });
                    $("#search_brand2").chosen().change(function(){
                        loadShopList($("#search_brand2").val(),"2");
                    });
                },
                error : function() {
                    alert("加载商户列表失败！");
                }
            });
        }


        function loadShopList(pid,type)//加载代理商列表
        {

            $.ajax( {
                url:'${pageContext.request.contextPath}/shop/getShopListForSelect.ac',// 跳转到 action
                data:{pid:pid},
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    var html='<option value=""></option>';
                    for(var i=0;i<data.length;i++)
                    {

                        html+='<option value="'+data[i].sid+'">'+data[i].business_name+'</option>';

                    }

                    $("#search_shop"+type).html(html);
                    $('#search_shop'+type).chosen({
                        no_results_text : "未找到此选项!",
                        width:"100%"
                    });
                    $('#search_shop'+type).trigger("chosen:updated");
                },
                error : function() {
                    alert("加载店铺列表失败！");
                }
            });
        }
        //撤销
        function deleteCX(id){
            if(id.length>0){
                swal({
                    title: "您确定要撤销本次交易吗",
                    text: "撤销后将无法恢复，请谨慎操作！",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "撤销",
                    cancelButtonText:"取消",
                    closeOnConfirm: false
                }, function () {
                    //撤销操作
                    $.ajax( {
                        url:'${pageContext.request.contextPath}/baseDetail/deBase90Detail.ac',// 跳转到 action
                        data:{
                            id :id.toString()
                        },
                        type:'post',
                        cache:false,
                        dataType:'json',
                        success:function(data) {
                            if(data.success){
                                swal("撤销成功！", "您已经删除了这条信息。", "success");
                                $table2.bootstrapTable('refresh');
                            }else{
                                swal("撤销失败！", data.msg, "error");
                            }
                        },
                        error : function() {
                            alert("异常！");
                        }
                    });

                });
            }else{
                sweetAlert("无法操作！", "请勾选需要删除的信息!", "error");
            }
        }




        function showDetail(obj)
        {
            var html='';
            if(obj.source=="1")
            {
                html=getHtmlZD(obj);
            }
            else if(obj.source=="2")
            { html=getHtmlSD(obj);}
            else if(obj.source=="4")
            { html=getHtmlSTK(obj);}
            $("#fqxq").html(html);
             $('#myModal').modal();
            $("#myModal").modal('show');

        }
        function loadZDInfo(){
            var agent= $("#search_agent").val();
            var brand= $("#search_brand").val();
            var start= $("#search_startdate").val();
            var end= $("#search_enddate").val();
            $.ajax( {
                url:'${pageContext.request.contextPath}/baseDetail/loadZDInfo.ac',// 跳转到 action
                data:{agent:agent,brand:brand,start:start,end:end},
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    $("#zdddze").html("订单总额："+data.totalFee);
                    $("#zdfqze").html("发券总额："+data.cashFee);
                    $("#zdfyze").html("费用总额："+data.couponFee);
                    $("#zdddbs").html("订单总数："+data.deals);

                },
                error : function() {
                    alert("加载自动发券汇总失败！");
                }
            });
        }

        function    loadSDInfo(){

            var agent= $("#search_agent2").val();
            var brand= $("#search_brand2").val();
            var shop= $("#search_shop2").val();
            var start= $("#search_startdate2").val();
            var end= $("#search_enddate2").val();
            $.ajax( {
                url:'${pageContext.request.contextPath}/baseDetail/loadSDInfo.ac',// 跳转到 action
                data:{agent:agent,brand:brand,shop:shop,start:start,end:end},
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    $("#sdfqze").html("发券总额："+data.point);
                    $("#sdfqzs").html("发劵总数："+data.count);
                    $("#sdcxze").html("撤销总额："+data.pointc);
                    $("#sdcxzs").html("撤销总数："+data.countc);

                },
                error : function() {
                    alert("加载手动发券汇总失败！");
                }
            });
        }
        function  loadSTKInfo(){

            var start= $("#search_startdate3").val();
            var end= $("#search_enddate3").val();
            $.ajax( {
                url:'${pageContext.request.contextPath}/baseDetail/loadSTKInfo.ac',// 跳转到 action
                data:{start:start,end:end},
                type:'post',
                cache:false,
                dataType:'json',
                success:function(data) {
                    $("#stkze").html("兑卡总额："+data.point);
                    $("#stkzs").html("兑卡总数："+data.count);
                },
                error : function() {
                    alert("加载实体卡发券汇总失败！");
                }
            });
        }

    </script>
</body>


</html>
